package com.yurui.controller;


import com.yurui.entities.CommonResult;
import com.yurui.entity.Order;
import com.yurui.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("order")
public class OrderController {

    private OrderService orderService;

    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }


    @GetMapping("order")
    public CommonResult<String> order(long userId, long productId, int count, float money) {

        Order order = new Order();
        order.setUserId(userId);
        order.setProductId(productId);
        order.setCount(count);
        order.setMoney(money);
        order.setStatus(0);
        orderService.create(order);
        return new CommonResult<>("创建订单成功");
    }

}
